<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>制造计划页面</title>
<link rel="stylesheet" href="../../../layui/css/layui.css" media="all">
</head>
<body>
	<div class="demoTable">
	  搜索:
	  <div class="layui-inline layui-form">
			<select name="proId" id="proId"
				autocomplete="off" class="layui-input">
				<option></option>
			</select>
	  </div>
	  <div class="layui-inline layui-form">
			<select name="drugId" id="drugId"
				autocomplete="off" class="layui-input">
				<option></option>
			</select>
	  </div>
	  <button class="layui-btn" data-type="reload">搜索</button>
	</div>
	<table class="layui-hide" id="manufacturePlan" lay-filter="demo"></table>
 
 <script type="text/javascript" src="../../../res/js/base.js"></script>
<script src="../../../layui/layui.js"></script>
<script>

layui.use(['laydate', 'laypage', 'layer', 'table', 'upload', 'element','form'], function(){
	  var laydate = layui.laydate //日期
	  ,laypage = layui.laypage //分页
	  layer = layui.layer //弹层
	  ,table = layui.table //表格
	  ,upload = layui.upload //上传
	  ,element = layui.element //元素操作
	  ,form=layui.form;
	 
	  
	  //监听Tab切换
	  element.on('tab(demo)', function(data){
	    layer.msg('切换了：'+ this.innerHTML);
	    console.log(data);
	  });
	  
	  //执行一个 table 实例
	  table.render({
	     elem: '#manufacturePlan'
	    ,height: 490
	    ,url: getRootPath()+'manufacturePlan/findAll.action' //数据接口
	    ,page: true //开启分页
	    ,method:'post'
	    ,cols: [[ //表头
	       {type:'checkbox', fixed: 'left'}
	      /* ,{field: 'mpId', title: '制造计划ID', width:120, fixed: 'left'}
	      ,{field: 'proId', title: '生产计划ID', width:120, fixed: 'left'}
	      ,{field: 'conId ', title: '药品ID', width:120, fixed: 'left'}*/
	      ,{field: 'entName', title: '计划厂家', width:150}
	      ,{field: 'time', title: '制造时间', width:150}
	      ,{field: 'drugName', title: '药品名称', width:150}
	      ,{field: 'mpTask', title: '计划任务', width:150}
	      ,{field: 'mpFinished', title: '是否完成', width:150}
	      ,{field: 'mpUnfinished', title: '未完成部分', width:150}
	      ,{field: 'mpScheme', title: '处理方案', width:150}
	      ,{field: 'sort', title: '制造次数', width:100}
	    ]]
	  	,id: 'testReload'
	  });
	  
	  //监听工具条
	  table.on('tool(demo)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
	    var data = obj.data //获得当前行数据
	    ,layEvent = obj.event; //获得 lay-event 对应的值
	   });
	  
	  //条件查询
	  var $ = layui.$;
			  
	  $('.demoTable .layui-btn').on('click', function(){
		 var proId = $('#proId');
		 var drugId=$('#drugId');
		 //执行重载
	     table.reload('testReload', {
	       page: {
	         curr: 1 //重新从第 1 页开始
	       }
	       ,where: {
	    	   proId: proId.val(),
	    	   drugId: drugId.val()
	       }
	     });
	  });
	    var url = "../../../manufacturePlan/findAllsProduction.action";
		$.post(url,null,function(data){
			for(var i=0;i<data.length;i++){
				$("#proId").append("<option value="+data[i].proId+">"+data[i].entName+"</option>");
			}
			//form表单重新渲染
			form.render();
		});
		var url = "../../../manufacturePlan/findAllsDrug.action";
		$.post(url,null,function(data){
			for(var i=0;i<data.length;i++){
				$("#drugId").append("<option value="+data[i].drugId+">"+data[i].drugName+"</option>");
			}
			//form表单重新渲染
			form.render();
		});
	});
	  
</script>
</body>
</html>